package com.bw.module_mine.ui.login

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.os.bundleOf
import androidx.fragment.app.activityViewModels
import androidx.navigation.NavController
import androidx.navigation.Navigation
import com.bw.lib_common.IntentData
import com.bw.lib_common.base.BaseFragment
import com.bw.module_mine.R
import com.bw.module_mine.databinding.FragmentForgetPwdBinding
import com.bw.module_mine.ui.login.viewmodel.LoginViewModel


class ForgetPwdFragment : BaseFragment<LoginViewModel, FragmentForgetPwdBinding>() {
    private val mViewModel: LoginViewModel by activityViewModels()
    override val mLayoutResId: Int
        get() = R.layout.fragment_forget_pwd
    private lateinit var mNavController: NavController

    override fun initView() {
        mViewModel.setShowingFragmentTag(ForgetPwdFragment::class.java.simpleName)
        mNavController = Navigation.findNavController(mBinding.root)
    }

    override fun initData() {
        super.initData()
        mBinding.viewModel = mViewModel
    }
    override fun initListener() {
        super.initListener()

        //验证码
        mBinding.btnSmsCode.setOnClickListener {
            checkPhone()
        }
    }

    private fun checkPhone() {
        mNavController.navigate(R.id.action_forgetPwdFragment_to_smsCodeFragment, bundleOf(
            IntentData.KEY_ACTION_SMS_CODE to SmsCode.RESET.type)
        )
    }
}